// 云函数入口文件
const cloud = require('wx-server-sdk')
const axios = require('axios')
cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
    const { imageData,access_token } = event;
    const detectUrl = `https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token=${access_token}` // baiduToken是已经获取的access_Token      
    const { data } = await axios({
        url: detectUrl,
        method: 'POST',
        params: {
            image: imageData
        },
        dataType: 'json',
        header: { 'content-type': 'application/x-www-form-urlencoded' }
    })

    return  data ;
}